<!DOCTYPE HTML>
<html lang="en">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="Javascript笔试刷题小结（三）, Casey Lu&#39;s Blog">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>Javascript笔试刷题小结（三） | Casey Lu&#39;s Blog</title>
    <link rel="icon" type="image/png" href="/medias/maozhao.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>
    
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="Casey Lu's Blog" type="application/atom+xml">
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">Casey Lu's Blog</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>Index</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>Tags</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>Categories</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>Archives</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>About</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="Search" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">Casey Lu's Blog</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			Index
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			Tags
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			Categories
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			Archives
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			About
		</a>
          
        </li>
        
        
    </ul>
</div>

        </div>

        
    </nav>

</header>

    
<script src="/libs/cryptojs/crypto-js.min.js"></script>
<script>
    (function() {
        let pwd = '';
        if (pwd && pwd.length > 0) {
            if (pwd !== CryptoJS.SHA256(prompt('嘻嘻嘻，访问本文章需要密码')).toString(CryptoJS.enc.Hex)) {
                alert('密码错误哦~');
                location.href = '/';
            }
        }
    })();
</script>




<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/articleimages/20.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">Javascript笔试刷题小结（三）</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/Javascript/">
                                <span class="chip bg-color">Javascript</span>
                            </a>
                        
                            <a href="/tags/Leetcode/">
                                <span class="chip bg-color">Leetcode</span>
                            </a>
                        
                            <a href="/tags/%E7%AE%97%E6%B3%95/">
                                <span class="chip bg-color">算法</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E7%AC%94%E8%AF%95%E9%9D%A2%E8%AF%95/" class="post-category">
                                笔试面试
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>Publish Date:&nbsp;&nbsp;
                    2020-03-19
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>Word Count:&nbsp;&nbsp;
                    3.2k
                </div>
                

                

                
            </div>

        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>生命不息，刷题不止，hhhhhhhhhh …  可爱的我又来了<img class="emoji" draggable="false" alt="😝" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f61d.png"/></p>
<h2 id="1-Leetcode-1013-将数组分成和相等的三个部分"><strong>1. Leetcode 1013. 将数组分成和相等的三个部分</strong></h2>
<p>**思路一：**最开始看到题目的时候cc是这么想的，既然能分成三个部分，不妨先计算每个部分的和，然后只要能成功地截取两边的部分，中间部分肯定也满足条件了，就可以判定能划分。所以我把题目转化为寻找 <code>[0,i), [i,j), [j,num.length)</code>中的i和j，使得<code>sum(A[0]-A[i-1]) = totalSum/3</code> 且 <code>sum(A[j]-A[length-1] = totalSum/3)</code></p>
<p>代码就这么出炉了：</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var canThreePartsEqualSum = function(A) {
  if(A.length < 3){
    return false
  }
  let totalSum = A.reduce((pre,cur) => pre+cur) // 计算数组之和
  if(totalSum % 3 !== 0){ // 和不能被3整除，不可能存在划分
    return false
  }
  let partSum = totalSum / 3
  let i = 1, j = A.length-1
  let partA = A[0],partC = A[j]
  while(partA !== partSum || partB !== partSum){
    if(partA !== partSum){
      partA += A[i]
      i++
    }
    if(partB !== partSum){
      j--
      partB += A[j]
    }
    if(i >= j){
      return false
    }
  }
  return true 
}
</code></pre>
<p>运行结果：<br>
<img src="https://img-blog.csdnimg.cn/2020031317414650.png" alt="Leetcode运行结果"><br>
上面我这种方法是比较直接的两侧遍历法,我就叫做<strong>两头分割法</strong>了，（emmm 怎么感觉有点血腥）<br>
看了其他人的题解，还有如下方法，都比较简单:<br>
<strong>思路二、遍历计数法</strong>：也是像我上面一样，计算整个数组的和，进而得到每部分的和，从左到右遍历，记录遍历过的数值之和temp和与部分数目count</p>
<ul>
<li>当<code>temp= totalSum/3</code>的时候<code>sum = 0, cnt ++</code><br>
遍历过程中，count只要等于3都可以划分，当然大于也可以[0,0,0,0,0],所以count = 3 的时候就可以返回true</li>
</ul>
<pre class=" language-language-javascript"><code class="language-language-javascript">var canThreePartsEqualSum = function(A){
  let totalSum = A.reduce((pre,cur) => pre+cur)
  if(totalSum % 3 !== 0)  return false
  let temp = 0
  let cnt = 0
  for(let item in A){
    temp += A[item]
    if(temp === totalSum/3){
      temp = 0
      cnt ++
    }
    if(cnt === 3) return true
  }
  return false
}
</code></pre>
<p><img src="https://img-blog.csdnimg.cn/20200313183646240.png" alt="效率感人。。。"><br>
第二种看似代码简单，但实际的性能并不强，所以cc还是安利自己的血腥**“双头分割法”**（2333333），类似双头指针的原理。</p>
<h2 id="2-Leetcode-300-最长上升子序列"><strong>2. Leetcode 300. 最长上升子序列</strong></h2>
<p><strong>思路一：动态规划法</strong>：遍历一遍数组，记录当前位置的上升子序列长，和当前最长的上升子序列长，遍历结束，输出最长上升子序列长度即可，在i&gt;j的情况下，</p>
<ul>
<li>如果nums[i] &gt; nums[j], <code>maxLen[i] = max(maxLen[j]+1, maxLen[i])</code></li>
<li>如果nums[i] &lt;= nums[j],maxLen[i]不变</li>
<li>记录当前全局的max 也就是所有maxLen[i]中的最大值<br>
<img src="https://img-blog.csdnimg.cn/20200314111422246.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0ODczNzEw,size_16,color_FFFFFF,t_70" alt="图解动态规划思路"></li>
</ul>
<pre class=" language-language-javascript"><code class="language-language-javascript">var lengthOfLIS = function(nums){
  if(nums.length < 2){
    return nums.length
  }
  let max = 1
  let maxLens = new Array(nums.length).fill(1)
  for(let i = 1; i < nums.length; i++){
    for(let j = 0; j < i; j++){
      if(nums[i] > nums[j]){
        maxLens[i] = Math.max(maxLens[j]+1, maxLens[i])
      }
    }
    max = Math.max(maxLens[i], max)
  }
  return max
}
</code></pre>
<p>在上述遍历情况下的，时间复杂度:<code>O（n*n）</code>，空间复杂度：<code>O(n)</code>, 是否有可能简化遍历呢？可能需要我们重新设计状态定义</p>
<p><strong>思路二： 动态规划+二分查找法</strong>：结合二分查找，改变思路一中的双重for循环，可以将时间复杂度降至<code>O（nlogN）</code>,具体的思路就类似于插入排序，依旧是i&gt;j的情况下:</p>
<ul>
<li>当我们当前遍历的元素大于递增序列的尾元素时( <code>num[i] &gt; num[j]</code>)，把当前元素直接放到序列后面</li>
<li>否则(<code>num[i] &lt;= num[j]</code>)，把之前递增序列中第一个比当前元素大的元素替换为当前元素，插入后依然有序<br>
（比方，之前递增序列为[1,2,5,9],当前元素是4,那么就把序列替换为[1,2,4,9]，插入的过程就是使用二分查找）</li>
<li>这种方法得到的序列未必是方法一中最终的递增序列，但是长度和最长递增序列肯定是相同的</li>
</ul>
<pre class=" language-language-javascript"><code class="language-language-javascript">var lengthOfLIS = function(nums){
  let n = nums.length
  if(n < 2){
    return n
  }
  let tail = new Array(n);
  tail[0] = nums[0]
  let end = 0
  for(let i = 1; i < n; i++){
    if(nums[i] > tail[end]){
      tail[++end] = nums[i]      
    }else{
      let left = 0
      let right = end
      while(left < right){
        let mid = left + ((right-left) >>1)
        if(tail[mid] < nums[i]){
          left = mid + 1
        }else{
          right = mid
        }
      }
      tail[left] = nums[i]
    }
  }
  return end + 1 
}
</code></pre>
<p>或者也可以这样写,通过更新新增的索引来求长度</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var lengthOfLIS = function(nums){
  let n = nums.length
  if(n < 2){
    return n
  }
  let tail = [nums[0]]
  for(let i = 0; i < n; i++){
    if(nums[i] > tail[tail.length-1]){
      tail.push(nums[i])
    }else{
      let left = 0
      let right = tail.length - 1
      while(left < right){
        let mid = (left + right) >> 1
        if(tail[mid] < nums[i]){
          left = mid + 1
        }else{
          right = mid
        }
      }
      tail[left] = nums[i]
    }
  }
  return tail.length
}
</code></pre>
<h2 id="3-Leetcode-695-岛屿的最大面积"><strong>3. Leetcode 695. 岛屿的最大面积</strong></h2>
<p><strong>思路一：</strong> <strong>万能的递归法+DFS</strong>，计算某个位置(i,j)处的岛屿面积,（i,j）处的岛屿面积情况如下：如果此处是岛屿，则他周围的岛屿面积等于1+四周的岛屿面积；否则返回0。遍历整个二维数组，记录每个(i,j)处的岛屿面积，记录最大值，输出</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var maxAreaOfIsland = function (grid) {
  let maxArea = 0
  // 查找相邻的岛屿面积
  const getArea = function(i, j){
    if(grid[i] === void 0 || grid[i][j] === void 0 || grid[i][j] === 0){
      return 0
    }
    // 如果该块已经被统计过了,置为0，防止重复统计
    grid[i][j] = 0
    return 1 + getArea(i-1,j) + getArea(i+1,j) + getArea(i,j-1) + getArea(i,j+1)
  }
  // 循环遍历找最大岛屿面积
  for(let i = 0; i < grid.length; i++){
    for(let j = 0; j < grid[i].length; j++){
      maxArea = Math.max(getArea(i,j), maxArea)
    }
  }
  return maxArea
};
</code></pre>
<p>时间和空间复杂度都是<code>O（m*n）</code><br>
<strong>思路二： 广度优先遍历（BFS）</strong>，遍历二维数组，<img class="emoji" draggable="false" alt="📝" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f4dd.png"/>借助队列记录非水区域块<code>grid[i][j]=1</code>的坐标<code>[i,j]</code>,和相关的区域面积<code>area</code>。每次都弹出队头，如果队头满足在区域内且是非水区域，则岛屿面积加一(<code>area++</code>)，同时弹入其四周的位置入队列；否则继续弹出队头，直到队列为空，更新最大面积(<code>maxArea = max（area, maxArea）</code>)。继续遍历二维数组，将非水区域的坐标放入空队列，初始化岛屿面积0,弹出队头元素，弹入… … 直到遍历结束，输出最大面积<code>maxArea</code></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var maxAreaOfIsland = function(grid){
  let maxArea = 0
  let row = grid.length, column = grid[0].length
  let dx = [1, -1, 0, 0], dy = [0, 0, 1, -1]
  for(let i = 0; i < row; i ++){
    for(let j = 0; j < column; j++){
      if(grid[i][j] === 0)  continue
      // 初始化小岛块区域的坐标和岛屿面积
      let queue = [[i,j]]
      let area = 0
      while(queue.length > 0){ // 队列不为空的时候
        let [x,y] = queue.shift() // 弹出队头位置的坐标
        if(x < 0 || x >= row ||y < 0 || y >= column || grid[x][y] === 0)  continue
        ++ area // 弹出的是范围内的非水块，面积加一
        grid[x][y] = 0 // 将该块标记为0，防止重复计算
        for(let k = 0; k < 4; k ++){
          queue.push([x+dx[k], y+dy[k]]) // 将四周的位置坐标弹入队列
        }
      }
      maxArea = Math.max(area, maxArea)
    }
  }
  return maxArea
};
</code></pre>
<p>或者也可以在弹入队列的时候就判断周围元素坐标范围，只让范围内的区域坐标<img class="emoji" draggable="false" alt="🌁" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f301.png"/>进队列，避免弹入又弹出的麻烦</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var maxAreaOfIsland = function(grid){
  let maxArea = 0
  let row = grid.length, column = grid[0].length
  let dx = [1,-1,0,0], dy = [0,0,1,-1]
  for(let i = 0; i < row; i++){
    for(let j = 0; j < column; j++){
      if(grid[i][j] === 0)  continue
      // 初始化非水块队列及岛屿面积
      let queue = [[i,j]]
      let area = 0
      while(queue.length > 0){
        // 弹出队头坐标，区域面积+1，置0防止重复计算
        let [x,y] = queue.shift()
        if(grid[x][y] === 0) continue
        ++ area
        grid[x][y] = 0
        // 弹入四周位置时，添加判断,满足条件再入队列
        for(let k = 0; k < 4; k ++){      
          // 判断是否在范围内
          if(x+dx[k] >= 0 && x+dx[k] < row && y+dy[k] >=0 && y+dy[k] < column){
            queue.push([x+dx[k],y+dy[k]])
          }
        }
      }
      maxArea = Math.max(area, maxArea)
    }
  }
  return maxArea
}
</code></pre>
<p>方法二的时间复杂度和空间复杂度依旧是<code>O(m*n)</code>，但实际在leetcode上运行的结果显示，DFS的运行效果要更优</p>
<h2 id="4-剑指offer-01-06-字符串压缩"><strong>4. 剑指offer 01.06. 字符串压缩</strong></h2>
<p><strong>思路：</strong> 统计字符串中连续出现的字符的数目，压缩后的新字符串<code>cstr = {char in str + count}*</code>，比较cstr 和 str 选择较短者</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var compressString = function(S){
  if(S.length < 2)  return S
  let res = ''
  let c = S[0]
  let cnt = 1
  for(let i = 1; i < S.length; i++){
    if(c === S[i]){
     cnt ++
    }else{
      res += c + cnt.toString()
      c = S[i]
      cnt = 1
    }
  }
  res += c + cnt.toString()
  return res.length < S.length ? res : S  
}
</code></pre>
<h2 id="5-Leetcode-1160-拼写单词"><strong>5. Leetcode 1160. 拼写单词</strong></h2>
<p><strong>思路：</strong> 计算每个单词中字符的个数，遍历单词集中的每个单词中字符出现的次数，和字母集中的字符次数做对比，如果字母集中的字符的个数小于单词中的字符个数，则不能拼写，若单词中每个字符的个数都小于等于字母集中的字符个数，则可以拼写，计入长度</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var countCharacters = function(words, chars){
  let ans = 0
  let countChars = function(word, char){
    // 计算字符串word中出现字符char的次数
    let res = 0
    for(let item of word){
      res += item===char? 1: 0
    }
    return res
  }

  for(let word of words){
    let isSuccess = 1 // 标记是否可以拼词成功
    for(let letter of word){
      if(countChars(word, letter) > countChars(chars, letter)){
        isSuccess = 0
        break
      }
    }
    if(isSuccess === 1){
      ans += word.length
    }
  }
  return ans
};
</code></pre>
<p><strong>思路二：哈希计数法</strong>，遍历字母集chars用map记录每个字母出现的次数_set get has；遍历单词集words，检查每个字符并计数，复制一份map，check函数：检查字符w是否出现在map中，(map.has(i) &amp;&amp; map.get(i) &gt; 0)，出现则map中的次数减一</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var countCharacters = function(words, chars){
  let map = new Map()
  let count = 0
  for(let c of chars){
    map.set(c, map.has(c)? map.get(c)+1: 1)
  }
  for(let w of words){
    if(check(w, new Map(map))){
      count += w.length
    }
  }
  return count
};
function check(w, map){
  for(let i of w){
    if(map.has(i) && map.get(i) > 0){
      map.set(i, map.get(i)-1)
    }else{
      return false
    }
  }
  return true
}
</code></pre>
<h2 id="6-Leetcode-836-矩形重叠"><strong>6. Leetcode 836. 矩形重叠</strong></h2>
<p>**思路：**初次根据两个矩形的左下角坐标判断两矩形的相对位置，接下来我的说法也是将矩形当做点来看待，一共有四种情况，在每种情况下，判断圈中的点与矩形1中点的位置关系，比如当矩形2在第二象限时，判断矩形2的右下角点A与矩形1的左上角点B的位置关系，如果A在B的右下方，两矩形重叠输出true,否则返回false，请看cc的抽象派手绘图</p>
<p><img src="https://img-blog.csdnimg.cn/2020031916143024.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0ODczNzEw,size_16,color_FFFFFF,t_70" alt="矩形位置关系分析"><br>
思路确定之后，就是各种暴力的判断了：</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var isRetangleOverlap = function(rec1, rec2){
  //判断相对位置，比较每个位置上对应的两点 
  if(rec1[0] < rec2[0] && rec1[1] < rec2[1]){
    // 第一象限        
    return rec1[2] > rec2[0] && rec1[3] > rec2[1] 
  }
  else if(rec1[0] > rec2[0] && rec1[1] < rec2[1]){
    // 第二象限        
    return rec1[0] < rec2[2] && rec1[3] > rec2[1] 
  }
  else if(rec1[0] > rec2[0] && rec1[1] > rec2[1]){
    // 第三象限        
    return rec1[0] < rec2[2] && rec1[1] < rec2[3] 
  }
  else{
    // 第四象限
    return rec1[2] > rec2[0] && rec1[1] < rec2[3]
  }
  return false
}
</code></pre>
<p>这个思路不算复杂，但代码看起来非常的难缠，有没有更简便的方法呢，围观了大佬的做法</p>
<p><strong>思路二</strong>：在一维的情况下，如果判断两个线段是否相互重叠，例如<code>[l1,r1]</code> 和 <code>[l2,r2]</code>，如果两线段重叠的话，必有<code>max(l1,l2) &lt; min(r1,r2)</code>同样，扩展到二维的情况下，我们不直接比较两个矩形，而是分别比较两个矩形在x轴和y轴上的投影线段，如果两轴上的投影线段都重合，那说明两个矩形必定垂直。两矩形在x轴上的投影线段分别为<code>[rec1[0], rec1[2]]</code> 和<code>[rec2[0], rec2[2]]</code>，在y轴上的投影线段分别为<code>[rec1[1], rec1[3]]</code>和<code>[rec2[1], rec2[3]]</code></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var isRectangleOverlap = function(rec1, rec2){
  return (Math.max(rec1[0],rec2[0]) < Math.min(rec1[2],rec2[2]))&& (Math.max(rec1[1],rec2[1]) < Math.min(rec1[3],rec2[3]))
}
</code></pre>
<p>大佬就是大佬！<img class="emoji" draggable="false" alt="👍" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f44d.png"/> 某人判断半天的语句，大佬一行代码return！流下了没技术的泪水</p>
<h2 id="7-Leetcode-409-最长回文串">7.Leetcode 409.最长回文串</h2>
<p><strong>思路：</strong> 利用Hash表统计字符串中每个字符出现的次数cnt，使用数组存放提高效率，若出现的次数为偶数，<code>res +=cnt</code>; 若出现的次数为奇数, <code>len += cnt-1</code>, 最后如果回文串长度小于总字符串长度<code>res &lt; s.length</code>，说明可以加上一个字母放在回文串正中央，return res + 1</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var longestPalindrome = function(s){
  if(s.length === 0) return 0
  s = s.split('') // 将字符串划分为Array
  let counts = new Array(58).fill(0) // A是65，a是97
  let res = 0
  s.filter(item => {
    counts[(item.charCodeAt()-65)] ++
  })
  for(let i = 0 ; i < counts.length && counts[i] > 0; i++){
    res += counts[i]%2 ? counts[i]-1 : counts[i]
  }
  return res < s.length ? res+1: res
}
</code></pre>
<h2 id="8-Leetcode-118-杨辉三角">8.Leetcode 118.杨辉三角</h2>
<p><strong>思路：</strong> 两层循环即可，每一行数据的首尾部放1，其余位置元素为<code>arr[i][j] = arr[i-1][j-1]+arr[i-1][j]</code></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var generate = function(numRows) {
  let resArr = []
  if(numRows <= 0) return resArr
  for(let i = 0; i < numRows; i++){
     let row = []
     for(let j = 0; j < i; j ++){
       if(j === 0 || j === i-1){
         row.push(1)
         continue
       }
       row.push(resArr[i-1][j-1] + resArr[i-1][j])
     }
     resArr.push(row)
  }
  return resArr
}
</code></pre>
<h2 id="9-Leetcode-119-杨辉三角-II">9.Leetcode 119.杨辉三角 II</h2>
<p><strong>思路：</strong> 和上面的差距就在于直接输出第k行的结果，可以直接用上面的办法，令numRows = k，输出第k行的row即可</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var getRow = function(rowIndex){
  let res = []
  for(let i = 0; i < rowIndex; i++){
    res.push(1)
    for(let j = i; j > 0; j--){
      res[j] += res[j-1] 
    }
  }
  res.push(1)
  return res
}
</code></pre>
<p><img class="emoji" draggable="false" alt="💭" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f4ad.png"/> 但是相比动态更新上面每一层的方法<code>O(n*n)</code>，有没有办法可以优化算法的复杂度到O（k）<img class="emoji" draggable="false" alt="❓" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/2753.png"/> 有的有的<img class="emoji" draggable="false" alt="❗️" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/2757.png"/><br>
利用递推公式，学过组合数学的同学一定非常清楚了，杨辉三角中的每层中的每一项都可以看做是一个组合数列，如图：<br>
<img src="https://img-blog.csdnimg.cn/20200319193703718.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0ODczNzEw,size_16,color_FFFFFF,t_70#pic_center" alt="把杨辉三角看作组合数列"><br>
因此就可以使用递推公式，逐项通过递推关系求解第k行的数值,递推公式为<code>C(n，k) =  C(n, n-k) * (n-k+1) / k! </code> 和<code>C(n,k) / C(n,k-1) = (n - k +1) / k</code></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var getRow = function(rowIndex){
  let res = [1]
  if(rowIndex === 0) return res
  let value = 1
  for(let i = 1; i <= rowIndex; i++){
    res[i] = value * (rowIndex - i + 1) / i
    value = res[i]
  }
  return res
}
</code></pre>
<h2 id="10-牛客美团面试题——数组的前置和与后置和相等的子数组的个数">10. 牛客美团面试题——数组的前置和与后置和相等的子数组的个数</h2>
<p><strong>题目：</strong> 一个数组x[]，数组每一个元素都大于0，称x[0] + …+ x[i]为前置和，而x[j] + … + x[n-1]为后置和，写一个程序，求x有多少相同的前置和后置和。</p>
<blockquote>
<p>示例 :[1, 2, 5,1, 8, 9, 7, 1] 前置[1,2,5] = 后置[1,7] ，即找到类似这样的子数组的个数。</p>
</blockquote>
<p><strong>思路：</strong> 在牛客面经里看到的，应该是双指针吧，然后计算前置和后置数组的值，由于数组都是正数，<code>left &lt; right</code>, 左边指针右滑，<code>left &gt; right</code> 时，右边指针左滑，left = right时，个数+1</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var findEqualArray = function(nums){
  if(nums.length <= 1) return 0
  let cnt = 0
  let i = 0, j = nums.length-1
  let left = num[i], right = nums[j]
  while(i < j){
     if(left === right){
       cnt ++
     }else if(left < right){
       i++
       left += nums[i]
     }else{
       j--
       right += nums[j]
     }
  }
  return cnt
}
</code></pre>
<p>最近要开始各种笔试面试了，加油啊！冲冲冲  <img class="emoji" draggable="false" alt="🌙" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f319.png"/></p>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        Author:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caseylu.gitee.io" rel="external nofollow noreferrer">Casey Lu</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        Link:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caseylu.gitee.io/2020/03/19/17-javascript-bi-shi-shua-ti-xiao-jie-san/">https://caseylu.gitee.io/2020/03/19/17-javascript-bi-shi-shua-ti-xiao-jie-san/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        Reprint policy:
                    </i>
                </span>
                <span class="reprint-info">
                    All articles in this blog are used except for special statements
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    reprint polocy. If reproduced, please indicate source
                    <a href="https://caseylu.gitee.io" target="_blank">Casey Lu</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>Copied successfully, please follow the reprint policy of this article</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">more</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/Javascript/">
                                    <span class="chip bg-color">Javascript</span>
                                </a>
                            
                                <a href="/tags/Leetcode/">
                                    <span class="chip bg-color">Leetcode</span>
                                </a>
                            
                                <a href="/tags/%E7%AE%97%E6%B3%95/">
                                    <span class="chip bg-color">算法</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">谢谢大佬的小鱼干，喵~</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            
        </div>
    </div>

    
        <link rel="stylesheet" href="/libs/gitalk/gitalk.css">
<link rel="stylesheet" href="/css/my-gitalk.css">

<div class="card gitalk-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="gitalk-container" class="card-content"></div>
</div>

<script src="/libs/gitalk/gitalk.min.js"></script>
<script>
    let gitalk = new Gitalk({
        clientID: 'b739596984975414aa79',
        clientSecret: 'c5792bc3376f951910111f232176fbadfa919286',
        repo: 'L0ittle.github.io',
        owner: 'L0ittle',
        admin: "L0ittle",
        id: '2020-03-19T20-37-02',
        distractionFreeMode: false  // Facebook-like distraction free mode
    });

    gitalk.render('gitalk-container');
</script>
    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;Previous</div>
            <div class="card">
                <a href="/2020/03/20/18-qian-duan-tu-pian-de-yu-lan-shang-chuan-jia-zai-ji-xia-zai/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/articleimages/18.jpg" class="responsive-img" alt="前端图片的预览和上传、加载及下载">
                        
                        <span class="card-title">前端图片的预览和上传、加载及下载</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            对于前端开发而言，和图片打交道自然是家常便饭。曾经的项目开发之中，对图片的使用也经历过不少问题，cc最近准备延伸一下，全方位的探讨在前端的多种应用场景下的图片操作，从预览上传、加载到下载到本地，同时也会分析图片的处理方式并share一些和图
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-03-20
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/" class="post-category">
                                    技术分享
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Javascript/">
                        <span class="chip bg-color">Javascript</span>
                    </a>
                    
                    <a href="/tags/LazyLoad/">
                        <span class="chip bg-color">LazyLoad</span>
                    </a>
                    
                    <a href="/tags/Axios/">
                        <span class="chip bg-color">Axios</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                Next&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/03/16/16-kua-yu-de-yuan-li-ji-jie-jue-fang-an/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/articleimages/12.jpg" class="responsive-img" alt="跨域的原理及解决方案">
                        
                        <span class="card-title">跨域的原理及解决方案</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            一、何为跨域
广义的跨域是指一个域下的文档和脚本试图请求另一个域下的资源。
举

资源跳转： A链接、重定向、表单提交
资源嵌入：&lt;link&gt;、&lt;script&gt;、&lt;img&gt;、&lt;frame&gt;等D
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-03-16
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/" class="post-category">
                                    技术分享
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Javascript/">
                        <span class="chip bg-color">Javascript</span>
                    </a>
                    
                    <a href="/tags/Ajax/">
                        <span class="chip bg-color">Ajax</span>
                    </a>
                    
                    <a href="/tags/Jsonp/">
                        <span class="chip bg-color">Jsonp</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('100')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + 'From: Casey Lu&#39;s Blog<br />'
            + 'Author: Casey Lu<br />'
            + 'Link: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>


<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;TOC</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="4892766072"
                   fixed='true'
                   autoplay='false'
                   theme:='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2020</span>
            <a href="https://caseylu.gitee.io" target="_blank">Casey Lu</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">63.2k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/L0ittle" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:caseylu119@163.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1351238945" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1351238945" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;Search</span>
            <input type="search" id="searchInput" name="s" placeholder="Please enter a search keyword"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Global site tag (gtag.js) - Google Analytics -->


    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
